import Vue from "vue";
import { imageUrl } from '@/config.js'
import urlConfig from "@/chronicDisease/request/urlConfig.js";
/**
 * @description 过滤请求的地址
 * @param {*} url 当前的地址
 * @returns {string}
 */
const filterUrl = (url) => {
	if (!url) return "";
	// 如果是完整地址了，就显示完整地址，否则拼接baseUrl
	if (/^http(s)?:\/\//.test(url)) return url;
	return imageUrl + url;
};
const filterImgUrl = (url) => {
	if (!url) return "";
	// 如果是完整地址了，就显示完整地址，否则拼接baseUrl
	if (/^http(s)?:\/\//.test(url)) return url;
	return urlConfig + url;
};
Vue.filter("filterUrl", filterUrl);
Vue.prototype.$filterUrl = filterUrl;
Vue.filter("filterImgUrl", filterImgUrl);
Vue.prototype.$filterImgUrl = filterImgUrl;